#coding:utf-8
'''
Created on 2019年2月20日

@author: wps
'''
import requests
import json


APPID = "wxb263655d7f7e0abc"
APPSECRET = "4d05ecfe08d00ba16e12cf4e904bfc75"



token_base_url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s'
token_url = token_base_url%(APPID, APPSECRET)
result = requests.get(token_url)
jsd = json.loads(result.text)
token = jsd.get('access_token')
print token
api_url = 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=%s'%token
del_url = 'https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=%s'%token
menu ='''
        {"button":[
                 {"type":"view",
                  "name":"天气情况",
                  "url":"http://hhl.applepais.com/page/weather"
                 },
                 {"name":"菜单",
                  "sub_button":[
                    {"type":"view",
                     "name":"搜索",
                     "url":"http://www.soso.com/"
                    },
                    {"type":"click",
                     "name":"赞我们",
                     "key":"V1001_GOOD"
                    }]
                 },
                 {"name":"菜1单",
                  "sub_button":[
                    {"type":"view",
                     "name":"搜索",
                     "url":"http://www.soso.com/"
                    },
                    {"type":"click",
                     "name":"赞我们",
                     "key":"V1001_GOOD"
                    }]
                 }]
            }
    '''
del_result = requests.get(del_url)
print del_result.text
creat_result = requests.post(api_url,data=menu)
print creat_result.text
# check_menu = requests.get('https://api.weixin.qq.com/cgi-bin/menu/get?access_token=%s'%token)
# print check_menu.text